const Mock = require('mockjs')
const fruit = Mock.mock('@shuffle(["山楂","西瓜","梨","菠萝","苹果" ,"香蕉","菠菜" ,"桃子","石榴"])')
const fruitvalue = fruit.map(v => {
    return Mock.mock({
        id: '@increment',
        pid: '@boolean()'
    })
})

fruit.forEach((v, i) => {
    fruitvalue[i].name = v
});
console.log(fruitvalue);
module.exports = [{
        url: '/admin/getAllCategory',
        type: 'get',
        response: config => {
            return {
                code: 20000,
                data: fruitvalue
            }
        }
    },
    {
        url: '/admin/delOneCategoryById',
        type: 'post',
        response: config => {
            const { id } = config.query
            return {
                code: 20000,
                data: 'success'
            }
        }
    },
    {
        url: '/admin/addOneCategory',
        type: 'post',
        response: config => {
            const { name } = config.query
            return {
                code: 20000,
                data: { id: 244, name: name }
            }
        }
    },
    {
        url: '/admin/editOneCategory',
        type: 'post',
        response: config => {
            const { name, id } = config.query
            return {
                code: 20000,
                data: 'success'
            }
        }
    },
    //二级
    {
        url: '/admin/addTwoCategory',
        type: 'post',
        response: config => {
            const { name } = config.query
            return {
                code: 20000,
                data: { id: 244, name: name }
            }
        }
    },
    {
        url: '/admin/editTwoCategory',
        type: 'post',
        response: config => {
            const { name, id } = config.query
            return {
                code: 20000,
                data: 'success'
            }
        }
    }, {
        url: '/admin/getTwoCategoryById',
        type: 'post',
        response: config => {
            const { id } = config.query
            return {
                code: 20000,
                data: fruitvalue
            }
        }
    },
    {
        url: '/admin/delTwoCategoryById',
        type: 'post',
        response: config => {
            const { id } = config.query
            return {
                code: 20000,
                data: 'success'
            }
        }
    },
]